<template>
  <div class="container">
    <van-nav-bar title="选择自提点" left-arrow @click-left="$router.back()" />
    <div :class="{item: 1, selected: defaultStationId===item.id}" v-for="item in list" :key="item.id" @click="select(item)">
      <div class="left">
        <div class="name">{{ item.name }}</div>
        <div class="concat">{{ item.concat }}</div>
        <div class="address">{{ item.address }}</div>
      </div>
      <img src="@/assets/img/go.png" class="go" />
    </div>
    <div style="height:200px" />
  </div>
</template>

<script>
import _ from 'lodash';
export default {
  data() {
    return {
      list: [],
      defaultStationId: null,
    }
  },
  mounted() {
    const { stationId } = this.$route.query;
    this.defaultStationId = stationId;
    this.getList();
  },
  methods: {
    async getList() {
      const data = await post('/list/station', { pageNo: 0, pageSize: 100 });
      if (data.success) {
        this.list = data.result.list;
      }
    },
    select(item) {
      this.$store.commit('setStation', item);
      this.$router.back();
    },
  }
}
</script>

<style scoped lang="less">
.container {
  width: 375px;
}
.item {
  padding: 10px 10px;
  border-bottom: 1px solid #d3d3d3;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}
.selected {
  color: red;
}
.name {
  font-size: 16px;
  font-weight: 800;
}
.concat {
  font-size: 16px;
  margin: 8px 0;
}
.address {
  font-size: 12px;
  color: gray;
}
.go {
  width: 10px;
  height: 20px;
}
</style>
